package com.itzb.asone.system.service.impl;


import java.util.List;

import com.itzb.asone.constant.SystemMessageConstant;
import com.itzb.asone.constant.model.SysApiConstant;
import com.itzb.asone.mybatis.Criteria;
import com.itzb.asone.system.model.SysApi;
import com.itzb.asone.system.repository.ISysApiRepository;
import com.itzb.asone.system.service.IMessageService;
import com.itzb.asone.system.service.ISysApiService;


public class SysApiServiceImpl implements ISysApiService{
	
	private ISysApiRepository sysApiRepository;
	private IMessageService messageService;

	public List<SysApi> queryPage(Criteria<SysApi> param){
		return sysApiRepository.queryPage(param);
	}

	public Integer queryPageCount(Criteria<SysApi> param){
		return sysApiRepository.queryPageCount(param);
	}

	public String getUrlByCode(String apiCode){
		Criteria<SysApi> param = new Criteria<SysApi>();
		param.addParam("apiCode", apiCode);
		param.addParam("apiStatus", SysApiConstant.T_SYS_API_STATUS_1);
		List<SysApi> list = this.queryPage(param);
		if(list == null || list.size() <= 0){
			messageService.message(SystemMessageConstant.SYSTEM_API_ERROR_01,apiCode);
			return null;
		}
		return list.get(0).getApiUrl();
	}
	public SysApi queryEntityById(String id){
		return sysApiRepository.queryEntityById(id);
	}

	public Integer insert(SysApi record){
		return sysApiRepository.insert(record);
	}

	public Integer updateByCriteria(Criteria<SysApi> param){
		return sysApiRepository.updateByCriteria(param);
	}

	public Integer deleteById(String id){
		return sysApiRepository.deleteById(id);
	}

	public Integer deleteByCriteria(Criteria<SysApi> param){
		return sysApiRepository.deleteByCriteria(param);
	}

	public ISysApiRepository getSysApiRepository() {
		return sysApiRepository;
	}

	public void setSysApiRepository(ISysApiRepository sysApiRepository) {
		this.sysApiRepository = sysApiRepository;
	}

	public IMessageService getMessageService() {
		return messageService;
	}

	public void setMessageService(IMessageService messageService) {
		this.messageService = messageService;
	}

}
